from PyQt4.QtGui import QDialog
from PyQt4.QtGui import QHBoxLayout, QVBoxLayout
from PyQt4.QtGui import QLineEdit

import config
from views.widgets.inputWidget import InputBox
from views.widgets.pushButton import PushButton


class LoginView(QDialog):
    def __init__(self, parent=None):
        super(LoginView, self).__init__(parent)
        self.setWindowTitle('Login')
        # input box
        self.nameInput = InputBox('username')
        self.passwordInput = InputBox('password')
        self.passwordInput.edit.setEchoMode(QLineEdit.Password)
        # login box
        self.loginBox = QHBoxLayout()
        self.loginButton = PushButton('login')
        self.signupButton = PushButton('Sign Up')
        self.temporaryButton = PushButton('Temporary')
        self.initLoginBox()
        # passwordBox
        self.passwordBox = QHBoxLayout()
        self.resetPassswordButton = PushButton('Reset Password')
        self.findPasswordButton = PushButton('Find Password')
        self.returnButton = PushButton('Return')
        self.initPasswordBox()
        # Layout
        self.mainLayout = QVBoxLayout(self)
        self.mainLayout.addLayout(self.nameInput)
        self.mainLayout.addLayout(self.passwordInput)
        self.mainLayout.addLayout(self.loginBox)
        self.mainLayout.addLayout(self.passwordBox)
        self.setLayout(self.mainLayout)

    def initLoginBox(self):
        self.loginBox.addWidget(self.loginButton)
        self.loginBox.addWidget(self.signupButton)
        self.loginBox.addWidget(self.temporaryButton)

    def initPasswordBox(self):
        self.passwordBox.addWidget(self.resetPassswordButton)
        self.passwordBox.addWidget(self.findPasswordButton)
        self.passwordBox.addWidget(self.returnButton)


if __name__ == '__main__' and config.DEBUG:
    from PyQt4 import QtGui
    import sys
    app = QtGui.QApplication(sys.argv);
    view = LoginView()
    view.show()
    sys.exit(app.exec_())
